<template>
	<view class="tuijianyouli">
		<view class="toubunei">

		</view>
		<view class="anniu">

			<view class="" @click="share()">
				<button open-type="share" class="btn">
					<image class="anniuimg" src="https://laileme123.oss-cn-shanghai.aliyuncs.com/bg/9dd3f94361504094813ac9a2fa775522.png"
					 mode=""></image>
				</button>
			</view>

		</view>
		<view class="yifenqishangp">
			<view class="fenlei">
				<view class="neirong">
					新鲜产品
				</view>
				<view class="neirong">
					一分起购
				</view>
				<view class="neirong">
					0元起送
				</view>
				<view class="neirong">
					30分钟送达
				</view>
			</view>
			<view class="shangpin">
				<view class="shangpinnei">
					<view class="shangpinneisp" v-for="item in yifengouList">
						<image class="tupian" :src="item.img" mode=""></image>
						<image class="dingweitupian" src="https://laileme123.oss-cn-shanghai.aliyuncs.com/bg/96b5dc06066c4896916e26dc58a27e20.png"
						 mode=""></image>
					</view>

				</view>

			</view>

		</view>
		<view class="yaoqing">
			<view class="hangxian">

			</view>
			<view class="yaoqngname">
				已邀请好友
			</view>
			<view class="hangxian">

			</view>

		</view>
		<view class="" style="margin-top: 32rpx;">
			<view class="haoyoulie" v-for="item in listBox">
				<view class="left">
					<image class="nechengoimg" :src="item.userDO.avatarUrl" mode=""></image>
					<view class="nicheng">
						<view class="wodename">
							{{item.userDO.nickname}}
						</view>
						<view class="dianhua">
							{{item.userDO.phone}}
						</view>
					</view>
				</view>
				<view class="zhuceshiji">
					注册时间：{{ formatDate(item.userDO.gmtCreate)}}
				</view>

			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				yifengouList: [],
				listBox: [],
				yaoqingma: '',
			}
		},
		onLoad(option) {


		},
		onShow() {
			this.gethuoqup()
			this.getyifengou()
			this.listin()

		},
		onShareAppMessage() {
			return {
				title: '1分好货分享你-新鲜食材，30分钟送达',
				// imageUrl: this.goods.img,
				path: '/pages/share/inviteNewPeople?p=' + this.yaoqingma
			};
		},
		methods: {
			//获取p
			gethuoqup() {
				let that = this;
				that.$api
					.request('activity', 'inviteBuyingInfo', failres => {
						that.logining = false;
						that.$api.msg(failres.errmsg);
					})
					.then(res => {
						
						that.yaoqingma = res.data.p
						console.log('获取p',that.yaoqingma)
					});
			},
			//我的邀请
			listin() {
				let that = this
				that.$api.request('activity', 'invitationList', failres => {
					that.logining = false
					that.$api.msg(failres.errmsg)
				}).then(res => {
					that.listBox = res.data
					console.log('我的邀请', that.listBox)

				})
			},
			formatDate(date) {
				var date = new Date(date);
				var YY = date.getFullYear() + '-';
				var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
				var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
				var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
				var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
				return YY + MM + DD + " " + hh + mm + ss;
			},
			//获取一分购数据
			getyifengou() {
				var that = this
				var obj = {}
				obj.activityType = 2,
					obj.pageNo = 1,
					obj.storageId = this.$store.state.storageId,
					this.$api
					.request('activity', 'activityGoodsList', obj, failres => {
						that.$api.msg(failres.errmsg);
						uni.hideLoading();
					})
					.then(res => {
						console.log(res)
						if (res.errno == '200') {
							that.yifengouList = res.data
							console.log('获取一分购数据', that.yifengouList)
						}
					});
			},
			//分享按钮
			share() {
				console.log('分享',this.yaoqingma)
				var that = this
				uni.showShareMenu({
					title: '1分好货分享你-新鲜食材，30分钟送达',
					// imageUrl: this.goods.img,
					path: '/pages/share/inviteNewPeople?p=' + that.yaoqingma,
					success(res) {
						console.log('成功', that.yaoqingma);
					},
					fail(res) {
						console.log('失败', that.yaoqingma);
					}
				});
			},
			//已经领取
			yijinglu() {
				uni.showToast({
					title: '已经领取了！',
					icon: 'none'
				});
			},
			//立即领取
			lijilingqu(item) {
				console.log('立即领取', item)
				if (item.min > this.userxinxi.signMoney) {
					uni.showToast({
						title: '积分不足！',
						icon: 'none'
					});
					return
				}

				var that = this
				var obj = {}
				obj.couponId = item.id
				that.$api
					.request('coupon', 'giveUserSignCoupons', obj, failres => {
						that.$api.msg(failres.errmsg);
						uni.hideLoading();
					})
					.then(res => {

						if (res.errno == '200') {
							that.$api.msg(res.errmsg);
							that.getalljuan()

						}
					});
			},
			//获取用户信息--签到次数
			getqiandao() {
				var that = this
				let obj = {};
				obj.userId = uni.getStorageSync('userInfo').id;
				that.$api
					.request('user', 'getUserInfo', obj, failres => {
						that.$api.msg(failres.errmsg);
						uni.hideLoading();
					})
					.then(res => {
						if (res.errno == '200') {
							if (res.data) {
								that.userxinxi = res.data
								console.log('that.userxinxi', that.userxinxi)
							}
						}
					});
			},
			//时间转换
			zhuanhaun(date) {
				var date = new Date(date);
				var YY = date.getFullYear() + '-';
				var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
				var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
				var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
				var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
				return YY + MM + DD + " " + hh + mm + ss;
			},

			//获取用户签到收益记录
			getalljuan() {
				var that = this
				that.$api
					.request('coupon', 'getSignCouponsList', {}, failres => {
						that.$api.msg(failres.errmsg);
						uni.hideLoading();
					})
					.then(res => {

						if (res.errno == '200') {

							that.duihuanfuliList = res.data
						}
					});
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F9F9F9;
	}

	.btn {
		background: none;
		border: none;

		&::after {
			border: none;

		}
	}

	.tuijianyouli {
		.haoyoulie {
			width: 750rpx;
			height: 112rpx;
			background: #FFFFFF;
			margin-bottom: 16rpx;
			background-color: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.zhuceshiji {
				font-size: 20rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #666666;
				margin-right: 24rpx;
			}

			.left {
				margin-left: 24rpx;
				display: flex;
				align-items: center;

				.nicheng {
					margin-left: 16rpx;

					.dianhua {
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
						margin-top: 5rpx;
					}

					.wodename {
						font-size: 28rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 600;
						color: #333333;
					}
				}

				.nechengoimg {
					width: 80rpx;
					height: 80rpx;
				}
			}
		}

		.yaoqing {
			height: 40rpx;
			width: 566rpx;
			margin-left: 92rpx;
			margin-top: 48rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.yaoqngname {
				font-size: 28rpx;
				font-family: PingFangSC-Semibold, PingFang SC;
				font-weight: 600;
				color: #333333;
			}

			.hangxian {
				width: 200rpx;
				height: 2rpx;
				background: linear-gradient(133deg, rgba(255, 255, 255, 0) 0%, #DDDDDD 100%);
				border-radius: 50rpx;
			}
		}

		.yifenqishangp {
			width: 702rpx;
			height: 416rpx;
			background: url('https://laileme123.oss-cn-shanghai.aliyuncs.com/bg/7ae33ac1f4554ac4a9c0cd06007926ed.png');
			background-size: 100% 100%;
			margin-top: 52rpx;
			margin-left: 24rpx;


			.shangpin {
				width: 100%;
				height: 180rpx;
				margin-top: 78rpx;
				overflow-y: hidden;
				overflow-x: auto;

				.shangpinnei {
					width: 800rpx;
					height: 180rpx;
					padding-left: 30rpx;
					display: flex;
					align-items: center;

					.shangpinneisp {
						width: 180rpx;
						height: 180rpx;
						margin-right: 16rpx;
						border-radius: 16rpx;
						position: relative;

						.dingweitupian {
							width: 80rpx;
							height: 40rpx;
							position: absolute;
							bottom: 0;
							right: 0;
						}

						.tupian {
							width: 180rpx;
							height: 180rpx;
							border-radius: 16rpx;
						}
					}
				}
			}

			.fenlei {
				height: 40rpx;
				width: 638rpx;
				padding-top: 110rpx;
				margin-left: 32rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.neirong {
					height: 40rpx;
					background: #FFFFFF;
					border-radius: 23rpx;
					padding-left: 22rpx;
					padding-right: 22rpx;
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #36B542;
					display: flex;
					align-items: center;
					justify-content: center;
				}

			}
		}

		.anniu {
			width: 702rpx;
			height: 88rpx;
			margin-left: 24rpx;
			margin-top: 32rpx;

			.anniuimg {
				width: 100%;
				height: 100%;
			}
		}

		.toubunei {
			width: 750rpx;
			height: 658rpx;
			background: url('https://laileme123.oss-cn-shanghai.aliyuncs.com/bg/2c84a03661414493a8cb72aef0bad94e.png');
			background-size: 100% 100%;
		}

	}
</style>
